Modeling the effect of continuous interactions of covariates with age on R2s

This code implements GAMM models for continuous variables including continuous x continuous interactions. Significance is tested using parametric bootstrapping.


Relevant functions:

GAMM modeling

# This function:
# 1. executes the GAMM model,
# 2. sends output to the parametric bootstrap (if requested),
# 3. prints a regression table, and 
# 4. sends the model to the visualizer for plotting.

gamm_model <- function(df, model_formula, this_label, smooth_var, int_var = NULL,weight_var = NULL,group_var, pbootstrap = F, longPlot = F, model_test = T){
  cat(sprintf("\n\n### Results for %s\n",this_label))
  if (is.null(weight_var)) {
    df$weight <- 1 #if no weighting variable is provided, weight all obs equally.
  } else {
    df$weight <- unlist(df[,weight_var]) # Use weight variable if provided.
  }

  model_formula <- as.formula(model_formula)
  if(!"exclusions" %in% colnames(df))  {
    df$exclusions <- FALSE; #there is no exclusions column so make one that excludes none
  }

  g1<-gamm(model_formula,
           data=df,
           random = list(bblid =~ 1),
           subset = exclusions == F,
           weights = weight)
  
  if (model_test == T){
    if (pbootstrap == T) {
      #Send to bootstrap function
      g1$pb<-pboot(g1) 
      #Print a table that shows the bootstrap outcome
      print(g1$pb %>%
        summary() %>%
        .$test %>%
        as.data.frame() %>%
        kable(caption = sprintf("Parametric Bootstrap test for %s",this_label)) %>%
        kable_styling(full_width = F, position = "left",bootstrap_options = c("striped"))
      )
      
      if (isTRUE(all.equal(g1$pb$bestmod,model_formula))) {
        cat("The initial (more complicated) model is best")
        g <- g1
        
        #This next part is no longer implemented (refit the model using unfixed degrees of freedom). Effective part is commented out below.
        if (str_detect(deparse(model_formula),"F1_Social_Cognition_Efficiency") &this_label == "Right_Pallidum_male") {
          plot_formula <- model_formula
        } else {
        plot_formula <- as.formula(gsub(", fx = T","",deparse(model_formula)))
        }
        cat(deparse(plot_formula))
        plotg<-g
        # plotg <- gamm(plot_formula,
        #               data = df,
        #               random = list(bblid =~1),
        #               subset = exclusions == F)
      } else {
        cat("The simpler model is best")
        
        g <-gamm(as.formula(g1$pb$bestmod),
                 data=df,
                 random = list(bblid =~ 1),
                 subset = exclusions == F,
                 weights = weight)
        
        #Again, this part not implemented (model not refit with unfixed df)
        plot_formula <- as.formula(gsub("ti\\(",'te\\(',deparse(g$gam$formula)) %>% gsub(", fx = T", "", .))
        plotg<-g
        # plotg <-gamm(plot_formula,
        #          data=df,
        #          random = list(bblid =~ 1),
        #          subset = exclusions == F)
      }
    } else {
      if (!is.null(int_var)) {
        # We are not bootstrapping, but there is an interaction variable
        s<-summary(g1$gam)
        if (s$s.table[grep(x=rownames(s$s.table),pattern = int_var),"p-value"] <.05)  {
          #Checked if interaction is sig, if so keep in the model
          g <- g1
          plot_formula <- as.formula(gsub(", fx = T", "", deparse(model_formula)))
          plotg <- g
        } else {
          #Interaction is not sig, remove from the model
          cat("The simpler model is best")
          thisResp <- as.character(g1$gam$terms[[2]])
          theseVars <- attr(terms(model_formula),"term.labels")
          new_formula <- reformulate(theseVars[0:(length(theseVars)-1)],response = thisResp)
          
          g <-gamm(as.formula(new_formula),
                   data=df,
                   random = list(bblid =~ 1),
                   subset = exclusions == F,
                   weights = weight)
          plot_formula <- as.formula(gsub("ti\\(",'te\\(',deparse(g$gam$formula)) %>% gsub(", fx = T", "", .))
          plotg<-g
      }
      } else {
        #There is no interaction term, just plot.
        g <- g1
          plot_formula <- as.formula(gsub(", fx = T", "", deparse(model_formula)))
          plotg <- g
      }
    }
  } else {
    g <- g1
    plotg<-g
  }

  g$gam$data<-df %>%
    filter(exclusions == F)
  
  #Display model results:
  
  s_tidytable<- tidy(g$gam)
  p_tidytable <- tidy(g$gam,parametric = T)
  snames = names(s_tidytable)
  pnames = names(p_tidytable)
  names(s_tidytable)=pnames
  thisBIC <- BIC(g$lme)
  numObs <- g$lme$dims$N
  g$BIC <- thisBIC
  stattable <- rbind(p_tidytable,snames,s_tidytable) %>%
    kable(caption = sprintf("Regression table from gamm in %s, BIC = %1.2f, obs = %d",this_label,thisBIC,numObs)) %>% 
    kable_styling(full_width = F, position = "left")
  print(stattable)
  
  #Send final model to visualizer:
  if (s_tidytable$p.value[nrow(s_tidytable)]<.05) {
    if (longPlot == T) {
      g$pl <- longitudinal_plot(g,plabels = this_label)
    } else {
      g$pl <- visualize_models(plotg,plabels = this_label, smooth_var = smooth_var, int_var = int_var, group_var = group_var)
    }
  }
  #Return result object
  result <- g
  
  return(result)
}

Bootstrap procedure

This procedure is lifted from https://github.com/PennBBL/groupAnalysis/wiki/Model-Comparison-Using-Parametric-Bootstrap

## Parametric bootstrap of likelihood ratio test for nested models
pboot <- function(modelobj){
  numsims <- 500

  df <- modelobj$gam$model
  thisResp <- as.character(modelobj$gam$terms[[2]])
  f1 <- modelobj$gam$formula
  theseVars <- attr(terms(f1),"term.labels")
  f2 <- reformulate(theseVars[0:(length(theseVars)-1)],response = thisResp)
  
  g1 <- gam(f1,data = df,weights = `(weights)`)
  g2 <- gam(f2,data = df,weights = `(weights)`)

  mat1 <- model.matrix(g1)
  mat2 <- model.matrix(g2)

  bblid<-df$bblid
  y <- df[,thisResp]
  w <- unlist(df[,"(weights)"])
  
  m1 <- lmer(y ~ -1 + mat1 + (1|bblid),weights = w)
  m2 <- lmer(y ~ -1 + mat2 + (1|bblid),weights = w)
  refdist <- PBrefdist(m1, m2, nsim=numsims)#, cl=cl)
  pb <- PBmodcomp(m1, m2, ref = refdist)
  int_pval <- pb$test["PBtest","p.value"]
  if (int_pval < .05) {
    pb$bestmod <- f1
  } else {
    pb$bestmod <- f2
  }
  return(pb)
}

Developmental effects

Fit nonlinear age effect and check for age*sex interaction (factor smooth interaction: s(age, by = oSex)) oSex is Sex specified as an ordered factor to appropriately test for the interaction (female against male reference)

model_formula <- "R2s ~ sequence + oSex + s(age,k=4, fx=T) + s(age, k=4, fx = T, by = oSex)"
models <- longTable %>%
    group_by(ROI)%>%
    nest()%>%
    mutate(results=purrr::pmap(list(data,model_formula,this_label = ROI, pbootstrap = F, longPlot = T),.f=gamm_model))

Results for Accumbens_Area

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Accumbens_Area, BIC = 6777.31, obs = 1448
term estimate std.error statistic p.value
(Intercept) 17.7725811888475 0.4418781558239 40.2205471227917 1.24633665554264e-237
sequenceB0map_onesizefitsall_v3 -0.623085998926579 0.448128328795958 -1.39041867895453 0.164616927635209
sequenceB0map_v4 2.24781461214699 0.478488410465983 4.69774097549807 2.88203097220329e-06
oSex.L 0.315735918185645 0.103193506624625 3.059649085617 0.00225694521495669
term edf ref.df statistic p.value
s(age) 3.00000000000002 3 20.4940934007221 5.26207497366208e-13
s(age):oSexfemale 3 3 0.400623669731159 0.75257585078062

Results for Putamen

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Putamen, BIC = 4611.75, obs = 1448
term estimate std.error statistic p.value
(Intercept) 16.6677215197485 0.208621890562926 79.8944035775628 0
sequenceB0map_onesizefitsall_v3 0.262161246096283 0.211676722521269 1.2384982296291 0.215733514212521
sequenceB0map_v4 0.237049079936652 0.227172304348336 1.04347702338385 0.296902802137554
oSex.L -0.0469991009696479 0.0475184636267328 -0.989070297786465 0.322795139823381
term edf ref.df statistic p.value
s(age) 3.00000000000003 3 46.5588980846991 1.0265049486821e-28
s(age):oSexfemale 2.99999999999998 2.99999999999998 2.4212879445373 0.0643878623448547

Results for Caudate

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Caudate, BIC = 5089.19, obs = 1448
term estimate std.error statistic p.value
(Intercept) 15.4077431686255 0.246834955589472 62.4212366187356 0
sequenceB0map_onesizefitsall_v3 -0.354827877293991 0.250019680916723 -1.41919978456487 0.156057495903268
sequenceB0map_v4 -0.0428467016925919 0.26477367095904 -0.161823875982065 0.871467283988404
oSex.L 0.115226724976578 0.060188115504299 1.91444314232346 0.0557618225737431
term edf ref.df statistic p.value
s(age) 3.00000000000001 3 6.65514367712182 0.000183646346673905
s(age):oSexfemale 3.00000000000003 3 0.101595291525597 0.959111961569524

Results for Pallidum

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Pallidum, BIC = 5563.05, obs = 1448
term estimate std.error statistic p.value
(Intercept) 21.726192506943 0.290143648014129 74.8808138852828 0
sequenceB0map_onesizefitsall_v3 0.644766152256348 0.29433364160001 2.19059618449108 0.0286410932291355
sequenceB0map_v4 0.142064726438526 0.315168217161323 0.450758416308865 0.652231631428754
oSex.L -0.0681025988146648 0.0668350226996268 -1.01896574675728 0.308390627537341
term edf ref.df statistic p.value
s(age) 2.99999999999999 2.99999999999999 100.984769127909 1.86338065267351e-61
s(age):oSexfemale 2.99999999999999 2.99999999999999 4.5818446773292 0.00336466095608642
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Warning: Removed 2 rows containing missing values (geom_path).
## Warning: Removed 2 rows containing missing values (geom_point).

2D smooth with additional main effects and tensor product smooth, ti: ti(age) + ti(Psychosis) + ti(age,Psychosis)

From documentation: This model specifies a main effects + interaction structure such as: y ~ ti(x) + ti(z) + ti(x,z)

ti is the proper way of specifying an interaction term in the context of included main effect terms:

“This functional ANOVA decomposition is supported by ti terms, which produce tensor product interactions from which the main effects have been excluded, under the assumption that they will be included separately. For example the ~ ti(x) + ti(z) + ti(x,z) would produce the above main effects + interaction structure. This is much better than attempting the same thing with s or te terms representing the interactions (although mgcv does not forbid it). Technically ti terms are very simple: they simply construct tensor product bases from marginal smooths to which identifiability constraints (usually sum-to-zero) have already been applied: correct nesting is then automatic (as with all interactions in a GLM framework). See Wood (2017, section 5.6.3).”

Cognitive Variables

Run the models:

cog_vars <- c("NAR_Overall_Accuracy","NAR_Overall_Efficiency","NAR_F2_Social_Cog_Accuracy","NAR_F1_Social_Cognition_Efficiency","mpraxis_mp2rtcr","wrat4_std")
## First the age models
    # model_formula <- sprintf("%s ~ sequence + timepoint + oSex + s(age,k=4, fx=T) + s(age, k=4, fx = T, by = oSex)",cv)
    # models <- dataTable %>%
    #   filter(scan2cnbmonths<6) %>%
    #   gamm_model(.,model_formula,
    #              this_label = cv,
    #              smooth_var = "age",
    #              group_var = "bblid",
    #              int_var = 'oSex',
    #              pbootstrap = T,
    #              longPlot = F)
    
for (r in rois) {
  cat(sprintf("\n## Results for %s\n",r))
  for (cv in cog_vars) {
    cat(sprintf("\n### %s\n",cv))
    thisTable <- dataTable
    if (cv == "mpraxis_mp2rtcr") {
      thisTable$exclusions <- thisTable$scan2cnbmonths>6 | thisTable$mpraxis_mp2rtcr>1500
    }
    else {
      thisTable$exclusions <- thisTable$scan2cnbmonths>6
    }
    
    # First check main effects
    add_formula <- sprintf("%s ~ sequence + timepoint + sex + s(age, k=4, fx = T) + s(%s, k=4, fx = T)",r,cv)
    gamm_model(thisTable,
               add_formula,
               this_label = sprintf("%s %s M.E.",r,cv),
               smooth_var = cv,
               group_var = "bblid",
               pbootstrap = F,
               model_test = F)
    
    # Compare the two interaction models
    cat('\n### Comparing interatcion models...\n')
    # Bivariate interaction
    bv_formula <- sprintf(
      "%s ~ sequence + timepoint + sex + ti(age, k=4, fx = T) + ti(%s, k=4, fx = T) + ti(age,%s, k=4, fx = T)",
      r,cv,cv)
    # Linear varying coefficient interaction
    vc_formula <- sprintf(
      "%s ~ sequence + timepoint + sex + s(age, k=4, fx = T) + s(age, by = %s, k=4, fx = T)",
      r,cv)
  
    bv <- gamm(as.formula(bv_formula),
               random = list(bblid=~1),
               data = thisTable,
               subset = thisTable$exclusions == 0)
    vc <- gamm(as.formula(vc_formula),
               random = list(bblid=~1),
               data = thisTable,
               subset = thisTable$exclusions == 0)
    bic<-BIC(bv$lme,vc$lme)
    bestmod <- gsub(row.names(bic)[which.min(bic$BIC)],pattern = "$lme",replacement = "", fixed = T)
    switch (bestmod,
      "bv" = {model <- bv},
      "vc" = {model <- vc}
    )
    model_formula <- model$gam$formula
    cat(sprintf("\n\nbest model is %s\n",deparse(model_formula)))
    a <- anova(model$gam)
    print(kable(a$pTerms.table)%>%kable_styling(position = "left"))
    print(kable(a$s.table)%>%kable_styling(position = "left"))
    
    
    # Now check if interaction is significant
    
    gamm_model(thisTable,
               model_formula,
               this_label = sprintf("%s %s final model",r,cv),
               smooth_var = "age",
               int_var = cv,
               group_var = "bblid",
               pbootstrap = F)

  }
}

Results for Caudate

NAR_Overall_Accuracy

Results for Caudate NAR_Overall_Accuracy M.E.

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Caudate NAR_Overall_Accuracy M.E., BIC = 4668.93, obs = 1315
term estimate std.error statistic p.value
(Intercept) 15.3529856190119 0.273281628437207 56.1800868459754 0
sequenceB0map_onesizefitsall_v3 -0.490199058971442 0.261730440869848 -1.87291572712097 0.061303780698564
sequenceB0map_v4 -0.0429404726639919 0.306550506633679 -0.140076338922202 0.888621323988869
timepoint.L -0.176818367568984 0.148542578887258 -1.19035477163209 0.234123803751784
timepoint.Q -0.14318414500882 0.0788423620581044 -1.81608137137365 0.0695876150199931
sexfemale 0.221803168549537 0.0903724894968453 2.45432177186266 0.0142451176928934
term edf ref.df statistic p.value
s(age) 2.99999999999999 2.99999999999999 5.25813154974345 0.00131397652817482
s(NAR_Overall_Accuracy) 2.99999999999999 2.99999999999999 0.738539519423275 0.529081070282189

Comparing interatcion models…

best model is Caudate ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +

best model is s(age, by = NAR_Overall_Accuracy, k = 4, fx = T)
df F p-value
sequence 2 4.764357 0.0086776
timepoint 2 1.622617 0.1977803
sex 1 6.297585 0.0122109
edf Ref.df F p-value
s(age) 3 3 4.035093 0.0071967
s(age):NAR_Overall_Accuracy 4 4 1.090170 0.3598747

Results for Caudate NAR_Overall_Accuracy final model

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2

The simpler model is best Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Caudate NAR_Overall_Accuracy final model, BIC = 4652.26, obs = 1316
term estimate std.error statistic p.value
(Intercept) 15.3538681544429 0.273259612632523 56.1878427863052 0
sequenceB0map_onesizefitsall_v3 -0.490418475926611 0.261300845588404 -1.87683463029855 0.0607633901279866
sequenceB0map_v4 -0.0402495851848337 0.306277785177037 -0.131415294000407 0.895467015996446
timepoint.L -0.179153292242278 0.148433705445786 -1.20695829632652 0.227666598247195
timepoint.Q -0.1477110647832 0.0788512266278031 -1.873288103436 0.0612516423736164
sexfemale 0.217916894308364 0.0899684063581489 2.42214909799418 0.0155643094616477
term edf ref.df statistic p.value
s(age) 2.99999999999999 2.99999999999999 8.79376273840496 8.93488116469911e-06

NAR_Overall_Efficiency

Results for Caudate NAR_Overall_Efficiency M.E.

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Caudate NAR_Overall_Efficiency M.E., BIC = 4667.08, obs = 1315
term estimate std.error statistic p.value
(Intercept) 15.3770937181106 0.27328530121216 56.2675476869972 0
sequenceB0map_onesizefitsall_v3 -0.529389140638872 0.261790641664416 -2.0221851219475 0.043361225556122
sequenceB0map_v4 -0.0713755038812788 0.306682355797909 -0.232734301572642 0.816004282703344
timepoint.L -0.214064828554569 0.149445198596866 -1.43239682883367 0.152270135056689
timepoint.Q -0.151606954796267 0.0790279204632367 -1.91839737029134 0.0552789604100243
sexfemale 0.217342490323903 0.0899435431092794 2.41643238425505 0.0158101528067682
term edf ref.df statistic p.value
s(age) 3 3 3.71630821654775 0.0111675572024455
s(NAR_Overall_Efficiency) 3 3 1.35563782621293 0.254825074839028

Comparing interatcion models…

best model is Caudate ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +

best model is s(age, by = NAR_Overall_Efficiency, k = 4, fx = T)
df F p-value
sequence 2 5.135467 0.0060041
timepoint 2 1.852837 0.1572048
sex 1 5.970541 0.0146789
edf Ref.df F p-value
s(age) 3 3 3.640933 0.0123796
s(age):NAR_Overall_Efficiency 4 4 0.988170 0.4128499

Results for Caudate NAR_Overall_Efficiency final model

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2

The simpler model is best Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Caudate NAR_Overall_Efficiency final model, BIC = 4652.26, obs = 1316
term estimate std.error statistic p.value
(Intercept) 15.3538681544429 0.273259612632523 56.1878427863052 0
sequenceB0map_onesizefitsall_v3 -0.490418475926611 0.261300845588404 -1.87683463029855 0.0607633901279866
sequenceB0map_v4 -0.0402495851848337 0.306277785177037 -0.131415294000407 0.895467015996446
timepoint.L -0.179153292242278 0.148433705445786 -1.20695829632652 0.227666598247195
timepoint.Q -0.1477110647832 0.0788512266278031 -1.873288103436 0.0612516423736164
sexfemale 0.217916894308364 0.0899684063581489 2.42214909799418 0.0155643094616477
term edf ref.df statistic p.value
s(age) 2.99999999999999 2.99999999999999 8.79376273840496 8.93488116469911e-06

NAR_F2_Social_Cog_Accuracy

Results for Caudate NAR_F2_Social_Cog_Accuracy M.E.

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Caudate NAR_F2_Social_Cog_Accuracy M.E., BIC = 4666.86, obs = 1315
term estimate std.error statistic p.value
(Intercept) 15.3307494359007 0.274075975681585 55.9361301105487 0
sequenceB0map_onesizefitsall_v3 -0.467228180710764 0.26227331311403 -1.78145528861957 0.0750709690682154
sequenceB0map_v4 -0.0131290204978989 0.307489534349389 -0.0426974548115217 0.965949250193631
timepoint.L -0.176519997647991 0.148049509707559 -1.19230383131068 0.233359222505338
timepoint.Q -0.144826953828754 0.0786746149936755 -1.84083460516961 0.065873045016694
sexfemale 0.221610929883039 0.0899898858147387 2.46262041424597 0.0139211927655693
term edf ref.df statistic p.value
s(age) 3 3 6.46345033011867 0.000242149601668248
s(NAR_F2_Social_Cog_Accuracy) 3 3 1.43127003414958 0.231959552260538

Comparing interatcion models…

best model is Caudate ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +

best model is s(age, by = NAR_F2_Social_Cog_Accuracy, k = 4, fx = T)
df F p-value
sequence 2 4.698218 0.0092665
timepoint 2 1.561555 0.2102023
sex 1 5.851337 0.0157016
edf Ref.df F p-value
s(age) 3 3 4.986321 0.0019210
s(age):NAR_F2_Social_Cog_Accuracy 4 4 1.498620 0.2002363

Results for Caudate NAR_F2_Social_Cog_Accuracy final model

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2

The simpler model is best Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Caudate NAR_F2_Social_Cog_Accuracy final model, BIC = 4652.26, obs = 1316
term estimate std.error statistic p.value
(Intercept) 15.3538681544429 0.273259612632523 56.1878427863052 0
sequenceB0map_onesizefitsall_v3 -0.490418475926611 0.261300845588404 -1.87683463029855 0.0607633901279866
sequenceB0map_v4 -0.0402495851848337 0.306277785177037 -0.131415294000407 0.895467015996446
timepoint.L -0.179153292242278 0.148433705445786 -1.20695829632652 0.227666598247195
timepoint.Q -0.1477110647832 0.0788512266278031 -1.873288103436 0.0612516423736164
sexfemale 0.217916894308364 0.0899684063581489 2.42214909799418 0.0155643094616477
term edf ref.df statistic p.value
s(age) 2.99999999999999 2.99999999999999 8.79376273840496 8.93488116469911e-06

NAR_F1_Social_Cognition_Efficiency

Results for Caudate NAR_F1_Social_Cognition_Efficiency M.E.

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Caudate NAR_F1_Social_Cognition_Efficiency M.E., BIC = 4665.98, obs = 1315
term estimate std.error statistic p.value
(Intercept) 15.4045132548449 0.273839373016732 56.2538289696698 0
sequenceB0map_onesizefitsall_v3 -0.551682477439182 0.262375900574415 -2.10264157733768 0.0356885412946827
sequenceB0map_v4 -0.114564064870278 0.307672503646249 -0.372357176909119 0.70968748552608
timepoint.L -0.222507736477729 0.149593893655985 -1.48741189255639 0.137148000188968
timepoint.Q -0.145688283230308 0.0789076524209203 -1.84631374474502 0.0650733341427244
sexfemale 0.204650286020993 0.0900501085326201 2.27262675587848 0.0232109750722581
term edf ref.df statistic p.value
s(age) 3 3 4.70303919565622 0.00285300610151464
s(NAR_F1_Social_Cognition_Efficiency) 3 3 1.72052754298838 0.160896028259027

Comparing interatcion models…

best model is Caudate ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +

best model is s(age, by = NAR_F1_Social_Cognition_Efficiency, k = 4, fx = T)
df F p-value
sequence 2 5.337299 0.0049146
timepoint 2 1.856833 0.1565797
sex 1 5.311020 0.0213477
edf Ref.df F p-value
s(age) 3 3 4.185903 0.0058429
s(age):NAR_F1_Social_Cognition_Efficiency 4 4 1.422772 0.2240915

Results for Caudate NAR_F1_Social_Cognition_Efficiency final model

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2

The simpler model is best Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Caudate NAR_F1_Social_Cognition_Efficiency final model, BIC = 4652.26, obs = 1316
term estimate std.error statistic p.value
(Intercept) 15.3538681544429 0.273259612632523 56.1878427863052 0
sequenceB0map_onesizefitsall_v3 -0.490418475926611 0.261300845588404 -1.87683463029855 0.0607633901279866
sequenceB0map_v4 -0.0402495851848337 0.306277785177037 -0.131415294000407 0.895467015996446
timepoint.L -0.179153292242278 0.148433705445786 -1.20695829632652 0.227666598247195
timepoint.Q -0.1477110647832 0.0788512266278031 -1.873288103436 0.0612516423736164
sexfemale 0.217916894308364 0.0899684063581489 2.42214909799418 0.0155643094616477
term edf ref.df statistic p.value
s(age) 2.99999999999999 2.99999999999999 8.79376273840496 8.93488116469911e-06

mpraxis_mp2rtcr

Results for Caudate mpraxis_mp2rtcr M.E.

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Caudate mpraxis_mp2rtcr M.E., BIC = 4670.85, obs = 1316
term estimate std.error statistic p.value
(Intercept) 15.3474896469627 0.272938738251096 56.2305290385107 0
sequenceB0map_onesizefitsall_v3 -0.493369424785766 0.261034914617774 -1.89005147264761 0.0589726799128901
sequenceB0map_v4 -0.0279431588185841 0.306065316149876 -0.0912980247814186 0.927269809657064
timepoint.L -0.190297424910458 0.148183443610887 -1.28420166432465 0.199299513080264
timepoint.Q -0.154231733945406 0.0787542250150184 -1.95839313911087 0.0503968242226789
sexfemale 0.223319171363192 0.0901821494337532 2.47631236076536 0.0134008685469919
term edf ref.df statistic p.value
s(age) 3.00000000000001 3 7.29798120041324 7.45758322910193e-05
s(mpraxis_mp2rtcr) 3 3 0.984725642647946 0.39908770557808

Comparing interatcion models…

best model is Caudate ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +

best model is s(age, by = mpraxis_mp2rtcr, k = 4, fx = T)
df F p-value
sequence 2 4.961769 0.0071334
timepoint 2 1.771671 0.1704579
sex 1 6.457642 0.0111628
edf Ref.df F p-value
s(age) 3 3 0.2626362 0.8523416
s(age):mpraxis_mp2rtcr 4 4 0.9992829 0.4068053

Results for Caudate mpraxis_mp2rtcr final model

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2

The simpler model is best Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Caudate mpraxis_mp2rtcr final model, BIC = 4652.26, obs = 1316
term estimate std.error statistic p.value
(Intercept) 15.3538681544429 0.273259612632523 56.1878427863052 0
sequenceB0map_onesizefitsall_v3 -0.490418475926611 0.261300845588404 -1.87683463029855 0.0607633901279866
sequenceB0map_v4 -0.0402495851848337 0.306277785177037 -0.131415294000407 0.895467015996446
timepoint.L -0.179153292242278 0.148433705445786 -1.20695829632652 0.227666598247195
timepoint.Q -0.1477110647832 0.0788512266278031 -1.873288103436 0.0612516423736164
sexfemale 0.217916894308364 0.0899684063581489 2.42214909799418 0.0155643094616477
term edf ref.df statistic p.value
s(age) 2.99999999999999 2.99999999999999 8.79376273840496 8.93488116469911e-06

wrat4_std

Results for Caudate wrat4_std M.E.

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Caudate wrat4_std M.E., BIC = 4645.33, obs = 1307
term estimate std.error statistic p.value
(Intercept) 15.3549043748491 0.27715789377554 55.4012882897879 0
sequenceB0map_onesizefitsall_v3 -0.493418129011292 0.265209926803257 -1.86048137397711 0.0630439874322876
sequenceB0map_v4 -0.0454157105988698 0.309675199629443 -0.146655950018646 0.88342641581938
timepoint.L -0.176057510334206 0.149407555619161 -1.17837086353902 0.238865267456396
timepoint.Q -0.153785014970552 0.0792948879260972 -1.93940642319691 0.0526688204839706
sexfemale 0.22584779824564 0.0903740901393986 2.49903260876296 0.0125763474175155
term edf ref.df statistic p.value
s(age) 3 3 9.028327805155 6.41155061519337e-06
s(wrat4_std) 3 3 0.705462687536168 0.548788080699956

Comparing interatcion models…

best model is Caudate ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +

best model is s(age, by = wrat4_std, k = 4, fx = T)
df F p-value
sequence 2 4.621176 0.0100042
timepoint 2 1.799607 0.1657774
sex 1 6.546723 0.0106207
edf Ref.df F p-value
s(age) 3 3 2.003046 0.1117195
s(age):wrat4_std 4 4 1.232055 0.2953177

Results for Caudate wrat4_std final model

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2

The simpler model is best Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Caudate wrat4_std final model, BIC = 4652.26, obs = 1316
term estimate std.error statistic p.value
(Intercept) 15.3538681544429 0.273259612632523 56.1878427863052 0
sequenceB0map_onesizefitsall_v3 -0.490418475926611 0.261300845588404 -1.87683463029855 0.0607633901279866
sequenceB0map_v4 -0.0402495851848337 0.306277785177037 -0.131415294000407 0.895467015996446
timepoint.L -0.179153292242278 0.148433705445786 -1.20695829632652 0.227666598247195
timepoint.Q -0.1477110647832 0.0788512266278031 -1.873288103436 0.0612516423736164
sexfemale 0.217916894308364 0.0899684063581489 2.42214909799418 0.0155643094616477
term edf ref.df statistic p.value
s(age) 2.99999999999999 2.99999999999999 8.79376273840496 8.93488116469911e-06

Results for Putamen

NAR_Overall_Accuracy

Results for Putamen NAR_Overall_Accuracy M.E.

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Putamen NAR_Overall_Accuracy M.E., BIC = 4237.48, obs = 1315
term estimate std.error statistic p.value
(Intercept) 16.6650322124337 0.234228454080503 71.1486240126316 0
sequenceB0map_onesizefitsall_v3 0.246149984528643 0.222390203333072 1.10683825474086 0.268568158837788
sequenceB0map_v4 0.248167388730185 0.268136140307857 0.925527563890696 0.354862931125977
timepoint.L -0.0920800033877545 0.138463486377791 -0.665012891099092 0.506159930247094
timepoint.Q -0.00295739469263832 0.076008782176485 -0.0389085919804837 0.968969226641507
sexfemale -0.0637579506172098 0.0712178354552013 -0.895252575561862 0.37081743180053
term edf ref.df statistic p.value
s(age) 3 3 58.8958261240417 3.51001013729215e-36
s(NAR_Overall_Accuracy) 3 3 1.03693236859079 0.375226343587529

Comparing interatcion models…

best model is Putamen ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +

best model is s(age, by = NAR_Overall_Accuracy, k = 4, fx = T)
df F p-value
sequence 2 0.6555408 0.5193325
timepoint 2 0.4229695 0.6551886
sex 1 0.6996755 0.4030462
edf Ref.df F p-value
s(age) 3 3 38.902648 0.000000
s(age):NAR_Overall_Accuracy 4 4 3.860154 0.004004

Results for Putamen NAR_Overall_Accuracy final model

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Putamen NAR_Overall_Accuracy final model, BIC = 4232.37, obs = 1315
term estimate std.error statistic p.value
(Intercept) 16.6413928229146 0.233553880163095 71.2529066581708 0
sequenceB0map_onesizefitsall_v3 0.254117160364681 0.222076473052776 1.14427772051428 0.252718799046043
sequenceB0map_v4 0.254976251321995 0.267268146719235 0.95400912698305 0.340256103318757
timepoint.L -0.0934372626660654 0.137814099395033 -0.677994944466711 0.497895367006877
timepoint.Q -0.0014050062851467 0.0756790550444156 -0.0185653254301618 0.985190708856292
sexfemale -0.0593295491251879 0.0709288142520089 -0.836466106910952 0.40304622557526
term edf ref.df statistic p.value
s(age) 2.99999999999999 2.99999999999999 38.9026475801087 3.4022123369098e-24
s(age):NAR_Overall_Accuracy 3.99999999999997 3.99999999999997 3.86015423011053 0.00400397327527081

[,1] [,2] [,3] [,4] [1,] 7.542472e-02 0.006573698 0.07513771 -0.07513771 [2,] 2.542808e-01 -0.022162030 -0.25331316 0.25331316 [3,] -1.567127e-17 0.360564139 -0.03154527 0.03154527 [4,] -1.216003e+00 -6.379376137 -3.60953854 4.60953854

NAR_Overall_Efficiency

Results for Putamen NAR_Overall_Efficiency M.E.

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Putamen NAR_Overall_Efficiency M.E., BIC = 4230.38, obs = 1315
term estimate std.error statistic p.value
(Intercept) 16.698914823609 0.233874046010328 71.4013166850994 0
sequenceB0map_onesizefitsall_v3 0.209443700129746 0.22211875725737 0.942935674212613 0.345888600676639
sequenceB0map_v4 0.191129700940256 0.267862065718406 0.71353776962649 0.475640828972058
timepoint.L -0.119974602553039 0.138733417252052 -0.864785175262193 0.3873158862359
timepoint.Q -0.0078700671549899 0.0760681761397918 -0.103460705308971 0.91761325564783
sexfemale -0.0770477468752721 0.070632811531029 -1.09082089761392 0.275553369734716
term edf ref.df statistic p.value
s(age) 3 3 57.4914869683459 2.41786495445284e-35
s(NAR_Overall_Efficiency) 3 3 3.41993103113196 0.0167525857993048

### Comparing interatcion models…

best model is Putamen ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +

best model is s(age, by = NAR_Overall_Efficiency, k = 4, fx = T)
df F p-value
sequence 2 0.3943468 0.6742007
timepoint 2 0.5777728 0.5612906
sex 1 0.9097077 0.3403690
edf Ref.df F p-value
s(age) 3 3 35.930157 0.0000000
s(age):NAR_Overall_Efficiency 4 4 4.484861 0.0013318

Results for Putamen NAR_Overall_Efficiency final model

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Putamen NAR_Overall_Efficiency final model, BIC = 4229.89, obs = 1315
term estimate std.error statistic p.value
(Intercept) 16.6534398476071 0.233481960544904 71.32645198259 0
sequenceB0map_onesizefitsall_v3 0.198081605588813 0.223044871191485 0.888079625102695 0.374661949558494
sequenceB0map_v4 0.194488238801518 0.2682797964525 0.724945528411985 0.468615709306448
timepoint.L -0.122962525798049 0.138213653393384 -0.889655419555932 0.373815284469178
timepoint.Q -0.0134895039640845 0.075793783951023 -0.177976388839503 0.858769204247666
sexfemale -0.0673115302884916 0.0705729836847655 -0.953786091702711 0.34036896870889
term edf ref.df statistic p.value
s(age) 2.99999999999999 2.99999999999999 35.9301589863937 2.12353924023525e-22
s(age):NAR_Overall_Efficiency 4.00000000000002 4 4.48486076256526 0.00133177872368856

[,1] [,2] [,3] [,4] [1,] 7.542472e-02 0.006573698 0.07513771 -0.07513771 [2,] 2.256165e-01 -0.019663771 -0.22475794 0.22475794 [3,] -1.375621e-17 0.316502485 -0.02769038 0.02769038 [4,] -1.136045e+00 -5.580758844 -3.75967139 4.75967139

NAR_F2_Social_Cog_Accuracy

Results for Putamen NAR_F2_Social_Cog_Accuracy M.E.

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Putamen NAR_F2_Social_Cog_Accuracy M.E., BIC = 4237.59, obs = 1315
term estimate std.error statistic p.value
(Intercept) 16.636919774286 0.235072344404564 70.7736157412612 0
sequenceB0map_onesizefitsall_v3 0.28124633047604 0.223036089232393 1.26099023455793 0.207538095550789
sequenceB0map_v4 0.289552680296303 0.269021816275903 1.07631672518092 0.28198487104667
timepoint.L -0.0843692153098241 0.138261196244847 -0.610216153203351 0.541825038549198
timepoint.Q -0.00792118670926243 0.0760086854529466 -0.10421423107187 0.917015378830021
sexfemale -0.0704731017044295 0.0709680476075913 -0.993025792312921 0.320881753252765
term edf ref.df statistic p.value
s(age) 2.99999999999998 2.99999999999998 67.2872104802061 3.50640110816644e-41
s(NAR_F2_Social_Cog_Accuracy) 2.99999999999999 2.99999999999999 1.00283322206155 0.390669681325008

Comparing interatcion models…

best model is Putamen ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +

best model is s(age, by = NAR_F2_Social_Cog_Accuracy, k = 4, fx = T)
df F p-value
sequence 2 0.6913462 0.5010851
timepoint 2 0.3424386 0.7101006
sex 1 1.0154849 0.3137796
edf Ref.df F p-value
s(age) 3 3 52.664294 0.0000000
s(age):NAR_F2_Social_Cog_Accuracy 4 4 1.550996 0.1851212

Results for Putamen NAR_F2_Social_Cog_Accuracy final model

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2

The simpler model is best Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Putamen NAR_F2_Social_Cog_Accuracy final model, BIC = 4221.28, obs = 1316
term estimate std.error statistic p.value
(Intercept) 16.6621015750286 0.234238731461152 71.1329909921066 0
sequenceB0map_onesizefitsall_v3 0.258560584141581 0.222104937043179 1.16413704073275 0.244580935685315
sequenceB0map_v4 0.253030961537692 0.267914446885347 0.944446872795835 0.345115891613633
timepoint.L -0.0810810983666827 0.13836830696386 -0.585980273559752 0.557989944432787
timepoint.Q -0.00248167275269385 0.0760409535340988 -0.0326360025401444 0.973969842237748
sexfemale -0.0714507108142841 0.0709276735627981 -1.00737423385278 0.313941427272422
term edf ref.df statistic p.value
s(age) 3.00000000000001 3 75.1915478052489 7.23150138429552e-45

NAR_F1_Social_Cognition_Efficiency

Results for Putamen NAR_F1_Social_Cognition_Efficiency M.E.

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Putamen NAR_F1_Social_Cognition_Efficiency M.E., BIC = 4233.76, obs = 1315
term estimate std.error statistic p.value
(Intercept) 16.6966011776676 0.234750429207961 71.124901598695 0
sequenceB0map_onesizefitsall_v3 0.21821323607531 0.223025312615328 0.978423630557494 0.32804646523073
sequenceB0map_v4 0.181827539620104 0.269146882644272 0.675569926107683 0.4994336131993
timepoint.L -0.118775105497918 0.139154381381338 -0.853549161146621 0.393511718155341
timepoint.Q -0.0036867313073501 0.0760482358866562 -0.0484788537743976 0.961342046294523
sexfemale -0.0838909786132601 0.070908094494869 -1.18309452835925 0.236987500796795
term edf ref.df statistic p.value
s(age) 3 3 64.394835656932 1.84975324094517e-39
s(NAR_F1_Social_Cognition_Efficiency) 3 3 2.28078405533107 0.0776087886723948

Comparing interatcion models…

best model is Putamen ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +

best model is s(age, by = NAR_F1_Social_Cognition_Efficiency, k = 4, fx = T)
df F p-value
sequence 2 0.2960739 0.7437826
timepoint 2 0.5681085 0.5667365
sex 1 1.2003598 0.2734524
edf Ref.df F p-value
s(age) 3 3 44.994999 0.000000
s(age):NAR_F1_Social_Cognition_Efficiency 4 4 2.875289 0.021858

Results for Putamen NAR_F1_Social_Cognition_Efficiency final model

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Putamen NAR_F1_Social_Cognition_Efficiency final model, BIC = 4236.29, obs = 1315
term estimate std.error statistic p.value
(Intercept) 16.6927560889044 0.23468002454728 71.1298548783872 0
sequenceB0map_onesizefitsall_v3 0.173064378504636 0.225347636918963 0.767988432764761 0.442633316674086
sequenceB0map_v4 0.162536423979961 0.27102524647008 0.599709532956387 0.548804181723978
timepoint.L -0.1256894431729 0.13894102223794 -0.904624430916115 0.365831741441191
timepoint.Q -0.016163342397436 0.076077221553019 -0.21245968329918 0.831781684196429
sexfemale -0.0775853442643686 0.0708147896770876 -1.09560932988934 0.273452393981232
term edf ref.df statistic p.value
s(age) 3.00000000000001 3 44.9949985646488 1.14666491542907e-27
s(age):NAR_F1_Social_Cognition_Efficiency 3.99999999999999 3.99999999999999 2.87528904025186 0.0218496835071634

[,1] [,2] [,3] [,4] [1,] 7.542472e-02 0.006573698 0.07513771 -0.07513771 [2,] 2.221663e-01 -0.019363072 -0.22132092 0.22132092 [3,] -1.987176e-17 0.457209010 -0.04000061 0.04000061 [4,] -1.191304e+00 -8.209308203 -3.47423350 4.47423350

mpraxis_mp2rtcr

Results for Putamen mpraxis_mp2rtcr M.E.

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Putamen mpraxis_mp2rtcr M.E., BIC = 4226.74, obs = 1316
term estimate std.error statistic p.value
(Intercept) 16.6619409417416 0.23285398875787 71.5553168344787 0
sequenceB0map_onesizefitsall_v3 0.250350753588452 0.22084037490989 1.13362764254771 0.257159141805902
sequenceB0map_v4 0.238265769180149 0.266476476665691 0.894134342218377 0.371415011643821
timepoint.L -0.0871266622549674 0.137544652369403 -0.633442745712658 0.526555638426535
timepoint.Q -0.00323387532386199 0.0756168998190862 -0.0427665684734372 0.965894161378631
sexfemale -0.059894926523171 0.0708066008823322 -0.845894673332866 0.397766696064266
term edf ref.df statistic p.value
s(age) 3 3 69.9045527160507 6.38485581794442e-42
s(mpraxis_mp2rtcr) 3 3 5.37706923857797 0.00111361920574243

### Comparing interatcion models…

best model is Putamen ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +

best model is s(age, by = mpraxis_mp2rtcr, k = 4, fx = T)
df F p-value
sequence 2 0.7718817 0.4623538
timepoint 2 0.3593921 0.6981698
sex 1 0.6194462 0.4313963
edf Ref.df F p-value
s(age) 3 3 6.712507 0.0001705
s(age):mpraxis_mp2rtcr 4 4 3.415595 0.0086760

Results for Putamen mpraxis_mp2rtcr final model

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Putamen mpraxis_mp2rtcr final model, BIC = 4236.37, obs = 1316
term estimate std.error statistic p.value
(Intercept) 17.0153626629912 0.30761421809013 55.3139668531374 0
sequenceB0map_onesizefitsall_v3 0.273768568852365 0.221194186948944 1.23768428378978 0.216056123998713
sequenceB0map_v4 0.284961355900336 0.2670356630456 1.06712846011012 0.28611150562952
timepoint.L -0.0909451580283361 0.138106916374643 -0.658512697377361 0.510325077148447
timepoint.Q -0.00550823275284094 0.075946700469652 -0.0725276110585213 0.942193163858906
sexfemale -0.0557978118663314 0.0708949599815814 -0.787049063584037 0.431396273059775
term edf ref.df statistic p.value
s(age) 2.99999999999907 2.99999999999907 6.71250634428106 0.000170165599296623
s(age):mpraxis_mp2rtcr 4.00000000000113 4 3.41559330239022 0.00868116043258085

[,1] [,2] [,3] [,4] [1,] 7.542472e-02 0.0065736978 0.075137709 -0.075137709 [2,] 1.414214e-03 -0.0001232568 -0.001408832 0.001408832 [3,] -1.585096e-17 0.3646985134 -0.031906986 0.031906986 [4,] -2.675064e+00 -6.2856959425 -2.153100417 3.153100417

wrat4_std

Results for Putamen wrat4_std M.E.

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Putamen wrat4_std M.E., BIC = 4207.10, obs = 1307
term estimate std.error statistic p.value
(Intercept) 16.5938029698312 0.236884245553377 70.0502599109832 0
sequenceB0map_onesizefitsall_v3 0.341320452523841 0.224764231598261 1.51857103817973 0.129114589274681
sequenceB0map_v4 0.303630078715588 0.270110960131226 1.12409388559456 0.261181521597634
timepoint.L -0.0496474196770763 0.138767384090419 -0.357774415094015 0.720570441291311
timepoint.Q 0.0042995826573627 0.076271926943631 0.0563717586490285 0.95505435046557
sexfemale -0.0626682170909903 0.0708930008054218 -0.883983134851269 0.376869399099073
term edf ref.df statistic p.value
s(age) 3 3 76.3883270826895 1.39642129821805e-46
s(wrat4_std) 3.00000000000001 3 2.35722639404123 0.0701602110752789

Comparing interatcion models…

best model is Putamen ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +

best model is s(age, by = wrat4_std, k = 4, fx = T)
df F p-value
sequence 2 1.3528373 0.2588711
timepoint 2 0.1980317 0.8203687
sex 1 0.4718535 0.4922588
edf Ref.df F p-value
s(age) 3 3 1.582250 0.1918558
s(age):wrat4_std 4 4 3.749673 0.0048616

Results for Putamen wrat4_std final model

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Putamen wrat4_std final model, BIC = 4206.36, obs = 1307
term estimate std.error statistic p.value
(Intercept) 16.1545507817039 0.326533662774922 49.4728495813282 1.24173449855074e-300
sequenceB0map_onesizefitsall_v3 0.367678173662801 0.224185715916317 1.64006066202739 0.101235603047662
sequenceB0map_v4 0.340021956104958 0.269622471756245 1.26110392019682 0.20749872115887
timepoint.L -0.060998785473273 0.138924727711238 -0.439077955942171 0.660678357121173
timepoint.Q 0.00185147270436671 0.0761048670242046 0.0243279145836739 0.980594798013176
sexfemale -0.048643641402101 0.0708145462973087 -0.686915950825624 0.492258775262108
term edf ref.df statistic p.value
s(age) 3.00000000000027 3 1.58224966813178 0.191864723337327
s(age):wrat4_std 4.00000000000071 4 3.74967243015373 0.00486159875133007

[,1] [,2] [,3] [,4] [1,] 7.542472e-02 0.006573698 0.07513771 -0.07513771 [2,] 1.571348e-02 -0.001369520 -0.01565369 0.01565369 [3,] -1.611060e-17 0.370672206 -0.03242962 0.03242962 [4,] -2.894424e+00 -6.832049497 -1.88510252 2.88510252

Results for Accumbens_Area

NAR_Overall_Accuracy

Results for Accumbens_Area NAR_Overall_Accuracy M.E.

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Accumbens_Area NAR_Overall_Accuracy M.E., BIC = 6179.35, obs = 1315
term estimate std.error statistic p.value
(Intercept) 17.3202093989911 0.489453261602499 35.3868505080214 8.80329164455521e-193
sequenceB0map_onesizefitsall_v3 -0.584994368448874 0.46600717378543 -1.25533339690223 0.209582834899325
sequenceB0map_v4 2.49937686621611 0.556881505008487 4.48816641195153 7.8180326728164e-06
timepoint.L -0.415022108260038 0.282255323920806 -1.47037831738644 0.14170074534393
timepoint.Q -0.129349074805991 0.152886987219103 -0.846043716072583 0.397683698780576
sexfemale 0.477075709478328 0.153006451699252 3.11801041184893 0.00186063173627339
term edf ref.df statistic p.value
s(age) 3 3 27.4616019845737 2.94267273067255e-17
s(NAR_Overall_Accuracy) 3.00000000000001 3 0.275916759180048 0.842805560764697

Comparing interatcion models…

best model is Accumbens_Area ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +

best model is s(age, by = NAR_Overall_Accuracy, k = 4, fx = T)
df F p-value
sequence 2 46.869899 0.0000000
timepoint 2 1.062619 0.3458491
sex 1 9.629774 0.0019557
edf Ref.df F p-value
s(age) 3 3 22.6873334 0.0000000
s(age):NAR_Overall_Accuracy 4 4 0.1609011 0.9580581

Results for Accumbens_Area NAR_Overall_Accuracy final model

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2

The simpler model is best Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Accumbens_Area NAR_Overall_Accuracy final model, BIC = 6163.66, obs = 1316
term estimate std.error statistic p.value
(Intercept) 17.3231454429973 0.489292395728258 35.4044853225518 4.43418463259289e-193
sequenceB0map_onesizefitsall_v3 -0.586019747346675 0.465248501374835 -1.25958438472119 0.208044210478284
sequenceB0map_v4 2.50598830714678 0.556119013698498 4.50620864494557 7.18967665536314e-06
timepoint.L -0.411829994648753 0.281761962665041 -1.46162381449031 0.144084700296036
timepoint.Q -0.132372674232584 0.15270695908686 -0.866841138243673 0.386188165882453
sexfemale 0.470975240710563 0.152438026248227 3.08961780929672 0.00204643523154119
term edf ref.df statistic p.value
s(age) 3.00000000000001 3 37.9586315818264 1.60945424979302e-23

NAR_Overall_Efficiency

Results for Accumbens_Area NAR_Overall_Efficiency M.E.

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Accumbens_Area NAR_Overall_Efficiency M.E., BIC = 6179.51, obs = 1315
term estimate std.error statistic p.value
(Intercept) 17.3333293003351 0.489932109406898 35.3790432746252 1.01362586563262e-192
sequenceB0map_onesizefitsall_v3 -0.604344401283538 0.466692625494864 -1.29495168397554 0.195566300620727
sequenceB0map_v4 2.48553331023352 0.557469658278193 4.45859837091469 8.95913840318396e-06
timepoint.L -0.435925387362487 0.283270652010582 -1.53890063890629 0.124071348003807
timepoint.Q -0.13669200622012 0.152985869809449 -0.893494323301726 0.371757503590785
sexfemale 0.472051627104423 0.152524967006234 3.09491381227526 0.00201063906680067
term edf ref.df statistic p.value
s(age) 3 3 25.5118863281632 4.8704473279279e-16
s(NAR_Overall_Efficiency) 3 3 0.221398763445024 0.881571309253921

Comparing interatcion models…

best model is Accumbens_Area ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +

best model is s(age, by = NAR_Overall_Efficiency, k = 4, fx = T)
df F p-value
sequence 2 46.722518 0.0000000
timepoint 2 1.024619 0.3592225
sex 1 9.527142 0.0020673
edf Ref.df F p-value
s(age) 3 3 20.0364139 0.0000000
s(age):NAR_Overall_Efficiency 4 4 0.2723447 0.8958936

Results for Accumbens_Area NAR_Overall_Efficiency final model

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2

The simpler model is best Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Accumbens_Area NAR_Overall_Efficiency final model, BIC = 6163.66, obs = 1316
term estimate std.error statistic p.value
(Intercept) 17.3231454429973 0.489292395728258 35.4044853225518 4.43418463259289e-193
sequenceB0map_onesizefitsall_v3 -0.586019747346675 0.465248501374835 -1.25958438472119 0.208044210478284
sequenceB0map_v4 2.50598830714678 0.556119013698498 4.50620864494557 7.18967665536314e-06
timepoint.L -0.411829994648753 0.281761962665041 -1.46162381449031 0.144084700296036
timepoint.Q -0.132372674232584 0.15270695908686 -0.866841138243673 0.386188165882453
sexfemale 0.470975240710563 0.152438026248227 3.08961780929672 0.00204643523154119
term edf ref.df statistic p.value
s(age) 3.00000000000001 3 37.9586315818264 1.60945424979302e-23

NAR_F2_Social_Cog_Accuracy

Results for Accumbens_Area NAR_F2_Social_Cog_Accuracy M.E.

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Accumbens_Area NAR_F2_Social_Cog_Accuracy M.E., BIC = 6179.67, obs = 1315
term estimate std.error statistic p.value
(Intercept) 17.3186501795022 0.491260118935362 35.2535235651418 9.77912049229311e-192
sequenceB0map_onesizefitsall_v3 -0.583699034673048 0.467417509178536 -1.2487744323033 0.211971897317657
sequenceB0map_v4 2.50689547865549 0.558825239293743 4.4860097618779 7.89632314107784e-06
timepoint.L -0.416038487139486 0.281699058289148 -1.47688987555097 0.139946795863701
timepoint.Q -0.128902580652174 0.152766531193384 -0.843788097073432 0.398942706132449
sexfemale 0.477216792761452 0.152519804792037 3.12888410401615 0.00179363522310833
term edf ref.df statistic p.value
s(age) 3 3 29.1373998031123 3.10460310452817e-18
s(NAR_F2_Social_Cog_Accuracy) 3.00000000000001 3 0.167978291832747 0.918004991497438

Comparing interatcion models…

best model is Accumbens_Area ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +

best model is s(age, by = NAR_F2_Social_Cog_Accuracy, k = 4, fx = T)
df F p-value
sequence 2 46.996460 0.0000000
timepoint 2 1.150490 0.3168032
sex 1 9.724345 0.0018583
edf Ref.df F p-value
s(age) 3 3 24.7549022 0.0000000
s(age):NAR_F2_Social_Cog_Accuracy 4 4 0.2013282 0.9376847

Results for Accumbens_Area NAR_F2_Social_Cog_Accuracy final model

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2

The simpler model is best Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Accumbens_Area NAR_F2_Social_Cog_Accuracy final model, BIC = 6163.66, obs = 1316
term estimate std.error statistic p.value
(Intercept) 17.3231454429973 0.489292395728258 35.4044853225518 4.43418463259289e-193
sequenceB0map_onesizefitsall_v3 -0.586019747346675 0.465248501374835 -1.25958438472119 0.208044210478284
sequenceB0map_v4 2.50598830714678 0.556119013698498 4.50620864494557 7.18967665536314e-06
timepoint.L -0.411829994648753 0.281761962665041 -1.46162381449031 0.144084700296036
timepoint.Q -0.132372674232584 0.15270695908686 -0.866841138243673 0.386188165882453
sexfemale 0.470975240710563 0.152438026248227 3.08961780929672 0.00204643523154119
term edf ref.df statistic p.value
s(age) 3.00000000000001 3 37.9586315818264 1.60945424979302e-23

NAR_F1_Social_Cognition_Efficiency

Results for Accumbens_Area NAR_F1_Social_Cognition_Efficiency M.E.

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Accumbens_Area NAR_F1_Social_Cognition_Efficiency M.E., BIC = 6179.33, obs = 1315
term estimate std.error statistic p.value
(Intercept) 17.3499555272956 0.491091767057146 35.3293553082039 2.48643646232657e-192
sequenceB0map_onesizefitsall_v3 -0.619930488727831 0.467941324128827 -1.324803894766 0.185468488605267
sequenceB0map_v4 2.47956274349106 0.559388868302178 4.43262796954983 1.0091346095056e-05
timepoint.L -0.43243430173355 0.283651048088906 -1.52452918699602 0.127619234849506
timepoint.Q -0.129500255582058 0.152710591474815 -0.848010961986322 0.396587611168561
sexfemale 0.470291621715911 0.152883363680925 3.07614648443654 0.00214062565384321
term edf ref.df statistic p.value
s(age) 3 3 28.9917271760017 3.4385290355452e-18
s(NAR_F1_Social_Cognition_Efficiency) 3 3 0.28000198136649 0.839863760014402

Comparing interatcion models…

best model is Accumbens_Area ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +

best model is s(age, by = NAR_F1_Social_Cognition_Efficiency, k = 4, fx = T)
df F p-value
sequence 2 46.790208 0.0000000
timepoint 2 1.173055 0.3097471
sex 1 9.091559 0.0026176
edf Ref.df F p-value
s(age) 3 3 25.0965293 0.0000000
s(age):NAR_F1_Social_Cognition_Efficiency 4 4 0.8921243 0.4678602

Results for Accumbens_Area NAR_F1_Social_Cognition_Efficiency final model

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2

The simpler model is best Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Accumbens_Area NAR_F1_Social_Cognition_Efficiency final model, BIC = 6163.66, obs = 1316
term estimate std.error statistic p.value
(Intercept) 17.3231454429973 0.489292395728258 35.4044853225518 4.43418463259289e-193
sequenceB0map_onesizefitsall_v3 -0.586019747346675 0.465248501374835 -1.25958438472119 0.208044210478284
sequenceB0map_v4 2.50598830714678 0.556119013698498 4.50620864494557 7.18967665536314e-06
timepoint.L -0.411829994648753 0.281761962665041 -1.46162381449031 0.144084700296036
timepoint.Q -0.132372674232584 0.15270695908686 -0.866841138243673 0.386188165882453
sexfemale 0.470975240710563 0.152438026248227 3.08961780929672 0.00204643523154119
term edf ref.df statistic p.value
s(age) 3.00000000000001 3 37.9586315818264 1.60945424979302e-23

mpraxis_mp2rtcr

Results for Accumbens_Area mpraxis_mp2rtcr M.E.

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Accumbens_Area mpraxis_mp2rtcr M.E., BIC = 6184.65, obs = 1316
term estimate std.error statistic p.value
(Intercept) 17.3180085901269 0.489268619937203 35.3957067435669 6.84338137207504e-193
sequenceB0map_onesizefitsall_v3 -0.587564764785295 0.465291762155578 -1.26278780880035 0.206891208593279
sequenceB0map_v4 2.52078156786512 0.556461893542805 4.53001651526603 6.43766301548061e-06
timepoint.L -0.42098964034866 0.281850007030076 -1.49366553077196 0.135504979382471
timepoint.Q -0.138344863892345 0.152859650543617 -0.905045009591132 0.365608723646604
sexfemale 0.473119277055444 0.152927317071723 3.09375254934703 0.00201843438749748
term edf ref.df statistic p.value
s(age) 3 3 34.6725348181068 1.46793428702995e-21
s(mpraxis_mp2rtcr) 3 3 0.186766934134985 0.905436038197559

Comparing interatcion models…

best model is Accumbens_Area ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +

best model is s(age, by = mpraxis_mp2rtcr, k = 4, fx = T)
df F p-value
sequence 2 46.1104300 0.0000000
timepoint 2 0.9593227 0.3834228
sex 1 9.9026310 0.0016878
edf Ref.df F p-value
s(age) 3 3 0.0360899 0.9908223
s(age):mpraxis_mp2rtcr 4 4 1.2645015 0.2819866

Results for Accumbens_Area mpraxis_mp2rtcr final model

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2

The simpler model is best Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Accumbens_Area mpraxis_mp2rtcr final model, BIC = 6163.66, obs = 1316
term estimate std.error statistic p.value
(Intercept) 17.3231454429973 0.489292395728258 35.4044853225518 4.43418463259289e-193
sequenceB0map_onesizefitsall_v3 -0.586019747346675 0.465248501374835 -1.25958438472119 0.208044210478284
sequenceB0map_v4 2.50598830714678 0.556119013698498 4.50620864494557 7.18967665536314e-06
timepoint.L -0.411829994648753 0.281761962665041 -1.46162381449031 0.144084700296036
timepoint.Q -0.132372674232584 0.15270695908686 -0.866841138243673 0.386188165882453
sexfemale 0.470975240710563 0.152438026248227 3.08961780929672 0.00204643523154119
term edf ref.df statistic p.value
s(age) 3.00000000000001 3 37.9586315818264 1.60945424979302e-23

wrat4_std

Results for Accumbens_Area wrat4_std M.E.

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Accumbens_Area wrat4_std M.E., BIC = 6149.25, obs = 1307
term estimate std.error statistic p.value
(Intercept) 17.3578564242176 0.497115928968418 34.917119755622 8.664254455773e-189
sequenceB0map_onesizefitsall_v3 -0.621268640274621 0.473091774054821 -1.31320955963743 0.189344977030271
sequenceB0map_v4 2.46069075079442 0.563014463153034 4.37056401182641 1.33837460909102e-05
timepoint.L -0.408987927814109 0.283440536744067 -1.4429408457669 0.14927896513991
timepoint.Q -0.133445632792116 0.153414375832877 -0.869837862766429 0.384550212144775
sexfemale 0.477518794863343 0.153489573696144 3.11108294436119 0.001904758089292
term edf ref.df statistic p.value
s(age) 3 3 37.0212924391122 5.920627011736e-23
s(wrat4_std) 3.00000000000001 3 0.0606958859794548 0.980418876514485

Comparing interatcion models…

best model is Accumbens_Area ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +

best model is s(age, by = wrat4_std, k = 4, fx = T)
df F p-value
sequence 2 45.2148025 0.0000000
timepoint 2 0.8645941 0.4214657
sex 1 9.1695450 0.0025095
edf Ref.df F p-value
s(age) 3 3 3.136645 0.0246412
s(age):wrat4_std 4 4 0.924000 0.4490601

Results for Accumbens_Area wrat4_std final model

Maximum number of PQL iterations: 20

## iteration 1
## iteration 2

The simpler model is best Maximum number of PQL iterations: 20

## iteration 1
## iteration 2
Regression table from gamm in Accumbens_Area wrat4_std final model, BIC = 6163.66, obs = 1316
term estimate std.error statistic p.value
(Intercept) 17.3231454429973 0.489292395728258 35.4044853225518 4.43418463259289e-193
sequenceB0map_onesizefitsall_v3 -0.586019747346675 0.465248501374835 -1.25958438472119 0.208044210478284
sequenceB0map_v4 2.50598830714678 0.556119013698498 4.50620864494557 7.18967665536314e-06
timepoint.L -0.411829994648753 0.281761962665041 -1.46162381449031 0.144084700296036
timepoint.Q -0.132372674232584 0.15270695908686 -0.866841138243673 0.386188165882453
sexfemale 0.470975240710563 0.152438026248227 3.08961780929672 0.00204643523154119
term edf ref.df statistic p.value
s(age) 3.00000000000001 3 37.9586315818264 1.60945424979302e-23

IQ Variables

Run the models:

cog_vars <- c("wrat4_std","wrat4_raw") #"wrat3_raw",
for (cv in cog_vars) {
  cat(sprintf("/n/n### Results for %s",cv))
  model_formula <- sprintf("R2s ~ sex + ti(age, k=4, fx = T) + ti(%s, k=4, fx = T) + ti(age,%s, k=4, fx = T)",cv,cv)
  thisTable <- longTable
  if (str_detect(cv,"wrat4")) {
    thisTable$exclusions <- thisTable$scan2cnbmonths>6 | thisTable$age>=40 #There is one old person
  } else {
    thisTable$exclusions <- thisTable$scan2cnbmonths>6
  }
  models <- thisTable %>%
      group_by(ROI)%>%
      nest()%>%
      mutate(results=purrr::pmap(list(data,model_formula,
                                      this_label = ROI,
                                      smooth_var = "age",
                                      int_var = cv,
                                      group_var = "bblid", 
                                      pbootstrap = T),
                                 .f=gamm_model))
}